<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Admin_Controller extends MY_Controller {

	var $navigation;
	/**
	 *
	 * Admin form object
	 * @var AdminForm
	 */
	public $form;
	/**
	 *
	 * Admin Grid object
	 * @var AdminGrid
	 */
	public $grid;

	function __construct () {
		parent::__construct();

		define("_CONTROLPANEL","TRUE");

		$this->load->helper('ssl');

		$this->load->model('admin/admin_model');
		if (!$this->admin_model->logged_in()){
			$this->_redirect(admin_url('admin/index/login'));
			die();
		}
		$this->load->library('admin_navigation');
		$this->admin_navigation->parent_link('dashboard','Bảng điều khiển',admin_url('*/dashboard/index'));
		$this->admin_navigation->parent_link('news',$this->__('Tin Tức'));
		$this->admin_navigation->parent_link('introduce','Giới thiệu', admin_url('*/introduce/manager_introduce'));
		$this->admin_navigation->parent_link('opening', 'Lịch khai giảng', admin_url('*/opening/manager_opening'));
		$this->admin_navigation->parent_link('contact', 'Liên hệ', admin_url('*/contact/manager_contact'));
		$this->admin_navigation->parent_link('general', 'General', admin_url('*/general/form_general'));
		$this->admin_navigation->parent_link('restaurant', 'restaurant', admin_url('*/restaurant/manager_restaurant'));
		$this->admin_navigation->parent_link('paper',$this->__('Paper'));


		$this->load->helper('string');
		$this->load->helper('directory');
		$this->load->helper('form');

		$this->load->library('headassets');


		$this->load->driver('cache');

		$modules = $this->module_model->get_module_folders();
		//var_dump($modules);

		$this->module_definitions = new stdClass();

		foreach ($modules as $module) {
			MY_Loader::define_module($module . '/');
		}

		$this->_setForm();
		$this->_setGrid();
	}

	private function _setForm(){
		if (is_null($this->form)){
			$this->load->library('AdminForm');
			$this->form = new AdminForm();
		}
		return $this->form;
	}

	private function _setGrid(){
		if (is_null($this->grid)){
			$this->load->library('AdminGrid');
			$this->grid = new AdminGrid();
		}
		return $this->grid;
	}

	function save_and_contine(){

	}
}